package com.greenhouse9.prog05.mypackage;

import java.util.HashMap;

public class Service implements java.io.Serializable {
    private String action = null;
	private String serviceName = null;
	private HashMap<String, String> httpParams = null;
	private Entity entity = null;

	public Service(){
	}

	public Service(HashMap<String, String> httpParams){
		this.httpParams = httpParams;
	}

	public Entity doService () {
		entity = new Entity();

		mainProcess();

		return entity;
	}

	protected void mainProcess () {

		serviceName = httpParams.get("calc");
		System.out.println("Service: " + serviceName);
		int value1 = Integer.parseInt(httpParams.get("value01"));
		int value2 = Integer.parseInt(httpParams.get("value02"));
		int kekka;

		if (serviceName.equals("plus")) {
			kekka = value1 + value2;
		} else {
			kekka = value1 - value2;
		}

		entity.setRecord(Integer.toString(kekka));

	}
}
